package com.smalljj.controller;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
 * 手机位置操作入口
 * @author Administrator
 *
 */
@Controller
@RequestMapping("position")
public class PositionController {

	@Autowired
    private Destination destination;
    
	@Autowired
	private JmsTemplate jmsTemplate;
	
	/**
	 * 
	 * 注明位置/坐标
	 * @param position
	 */
	@RequestMapping( value="/at_{position}",method=RequestMethod.GET )
	public void at(@PathVariable final String position) {
		this.jmsTemplate.send(this.destination, new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                TextMessage textMessage = session.createTextMessage();
                textMessage.setText(position);
                return textMessage;
            }
        });
	}
}
